package com.example.springbootdemo.异步注解失效测试.shedule;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class ScheduleTwo {
    @Scheduled(cron = "0 59 * * * ? ")
    public void test1() {
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("ScheduleTwo-----子线程1名："+Thread.currentThread().getName());
            System.out.println(String.format("第%d次执行任务一",i));
        }
    }
    @Scheduled(cron = "0 59 * * * ? ")
    public void test2() {
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("ScheduleTwo-----子线程2名："+Thread.currentThread().getName());
            System.out.println(String.format("第%d次执行任务二",i));
        }
    }
}
